package pack.model;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

/**
 * This class loads all textures used in the application.
 * @author henrik Larsson
 */
public class Art
{
	public static TextureRegion[][] player;	
	public static TextureRegion[][] enemy;
	public static TextureRegion[][] lever;
	public static TextureRegion[][]	door;
	public static TextureRegion		map;
	public static TextureRegion		wall;
	public static TextureRegion 	diamond;
	public static TextureRegion[][] goal;
	public static TextureRegion 	hole;
	public static TextureRegion		key;
	public static TextureRegion		hammer;
	



	public static void load()
	{ 
		player = split("data/player.png", 12, 12);
		enemy = split("data/enemy.png", 12, 12);
		lever = split("data/lever.png",12, 12);
		hammer = cut("data/hammer.png",13, 13);
		diamond = cut("data/diamond.png",12,12);
		wall = cut("data/wall.png",16,16);
		goal = split("data/goal.png",16,16);
		door = split("data/door.png",16,16);
		map = cut("data/map.png",320,240);		// map size in pixels
		key = cut("data/key.png",16,10);
		hole = cut("data/hole.png",16,16);
	}
	
	public static TextureRegion[][] split(String fileName, int width, int height)
	{
		Texture texture = new Texture(Gdx.files.internal(fileName));
		int xSlices = texture.getWidth() / width;
		int ySlices = texture.getHeight() / height;
		TextureRegion[][] res = new TextureRegion[xSlices][ySlices];
		for (int x = 0; x < xSlices; x++) {
			for (int y = 0; y < ySlices; y++) {
				res[x][y] = new TextureRegion(texture, x * width, y * height, width, height);
			}
		}
		return res;
	}
	
	public static TextureRegion cut (String fileName, int width, int height) {
		Texture texture = new Texture(Gdx.files.internal(fileName));
		TextureRegion region = new TextureRegion(texture, 0, 0, width, height);
		
		return region;
	}
	public static TextureRegion getMap()
	{
	 return map;	
	}
}